import java.io.IOException;
import java.net.InetSocketAddress;

import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.service.IoHandler;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.logging.LoggingFilter;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import Protocol.GameMassegeCodecFactory;


public class TDRServer 
{
	private static final int PORT = 10010;
	
	private static final Logger LOGGER = LoggerFactory.getLogger(TDRServer.class);
	

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub

		IoAcceptor acceptor = new NioSocketAcceptor();
		
		acceptor.getFilterChain().addLast("logger", new LoggingFilter());
		ProtocolCodecFactory factory = new GameMassegeCodecFactory();
		acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(factory));
		
		IoHandler handler = null;
		acceptor.setHandler(handler);
		
		try {
			acceptor.bind(new InetSocketAddress(PORT));
			LOGGER.info("TDR Server , port : "+PORT);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}




